﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajax({
            url: "../data/system.aspx?method=1508",
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    var tabs = parent.mini.get("mainTabs");
                    var tab = tabs.getTab("tab$1508");
                    tabs.removeTab(tab);
                }
            }
        });
        var AdType = [{ id: 1, text: '置顶广告(760*70)' }, { id: 2, text: '首页上横幅（全）广告(980*80)' }, { id: 3, text: '首页横幅（半）广告(485*70)' }, { id: 4, text: '图标招聘广告(150*40)' }, { id: 5, text: '首页挂边广告(130*340)' }, { id: 6, text: '首页下横幅（全）广告(980*80)'}];
    </script>
</head>
<body>
    <div class="mini-fit">
        <div id="divList" class="mini-fit">
            <div class="mini-toolbar" style="border-bottom: 0;">
                <table >
                    <tr>
                        <td>
                            <a class="mini-button" iconcls="icon-search" plain="true" onclick="search();">查询</a>
                            <span class="separator"></span>
                            <a class="mini-button" iconcls="icon-ok" plain="true" onclick="create()">生成</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-fit">
                <div id="datagrid1" class="mini-datagrid" style="width: 600px; height: 100%;" allowresize="true"
                    url="../data/system.aspx?method=GetHtmlList" idfield="id" multiselect="true" sizeList="[15,20,50,100]" pageSize="15">
                    <div property="columns">
                        <div field="ad_kind" width="120px" align="center" headeralign="center" renderer="onAdRenderer">栏目</div>
                        <div field="ad_count1" width="70px" align="center" headeralign="center">有效广告数</div>
                        <div field="ad_count2" width="70px" align="center" headeralign="center">过期广告数</div>
                        <div field="ad_count3" width="70px" align="center" headeralign="center">隐藏广告数</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            complete: function (XMLHttpRequest, textStatus) {
                if (XMLHttpRequest.responseText == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                }
            }
        });

        mini.parse();
        var grid = mini.get("datagrid1");
        search();

        //查询
        function search() {
            grid.load();
        }

        function onAdRenderer(e) {
            for (var i = 0; i < AdType.length; i++) {
                var a = AdType[i];
                if (a.id == e.value) {
                    var s = '<a class="linelink" title="查看" href="javascript:void(0);" onclick="lookRows(' + e.record._uid + ')">' + a.text + '</a>';
                    return s;
                }
            }
            return "";
        }

        //招聘显示
        function onCountRenderer(e) {
            var s = '<a class="linelink" title="详细" href="javascript:void(0);" onclick="lookRows(' + e.record._uid + ')">查看</a> (' + e.value + ')';
            return s;
        }

        //管理广告
        function lookRows(row_uid) {
            var row = grid.getRowByUID(row_uid);
            if (row) {
                showRTab(row.ad_kind);
            }
        }

        //打开管理广告Tab
        function showRTab(ad_type) {
            var tabs = parent.mini.get("mainTabs");
            var id = "tab$html";
            var tab = tabs.getTab(id);
            if (!tab) {
                tabs.removeTab(tab);
            }
            tab = {};
            tab.name = id;
            tab.title = "主网站广告管理";
            tab.showCloseButton = true;
            tab.url = "advertisement/manage.html?kind=" + ad_type;
            tabs.addTab(tab);
            tabs.activeTab(tab);
        }

        //生成
        function create() {
            mini.confirm("确定生成静态页面？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '操作中，请稍后...' });

                        $.ajax({
                            url: "../data/system.aspx?method=CreateHtml",
                            type: "post",
                            data: { webset: webset },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret == 1) {
                                    ShowMessage("系统提示", "静态页面生成成功！", 1);
                                }
                                else
                                    ShowMessage("系统提示", "静态页面生成失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "静态页面生成失败！", 3);
                            }
                        });
                    }
                }
            );
        }
    </script>
</html>
